﻿using System.Collections.Generic;
using System.IO;
using T68Control.S12L_M1;

namespace T68Control.Procdure
{
    internal class CsvTestReportGenerator : ITestReportGenerator
    {
        public void GenerateReport(List<string> headers, List<TestItem2> data, string filePath)
        {
            using (var writer = new StreamWriter(filePath))
            {
                writer.WriteLine(string.Join(",", headers));
                foreach (var item in data)
                {
                    //此处的字符串不能包含英文逗号，否则会被解析为两个字符串
                    writer.WriteLine($"{item.SN},{item.TotalResult},{item.TestTime},{item.Desc},{item.Result},{item.ErrMsg}");
                }
            }
        }
    }
}